/* -*-c++-*- */
/* osgGIS - GIS Library for OpenSceneGraph
 * Copyright 2007-2008 Glenn Waldron and Pelican Ventures, Inc.
 * http://osggis.org
 *
 * osgGIS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */

#ifndef _OSGGISPROJECTS_CELL_COMPILER_H_
#define _OSGGISPROJECTS_CELL_COMPILER_H_ 1

#include <osgGISProjects/Common>
#include <osgGIS/FeatureLayerCompiler>
#include <osgGIS/Report>
#include <osgGIS/ResourcePackager>
#include <osgGIS/SpatialReference>
#include <osgDB/Archive>

using namespace osgGIS;

namespace osgGISProjects
{

    class OSGGISPROJECTS_EXPORT CellCompiler : public FeatureLayerCompiler
    {
    public:
        enum OutputStatus
        {
            OUTPUT_UNKNOWN,
            OUTPUT_ALREADY_EXISTS,
            OUTPUT_NON_EMPTY,
            OUTPUT_EMPTY
        };

    public:
        CellCompiler(
            const std::string&     cell_id,
            const std::string&     abs_output_uri,
            FeatureLayer*          layer,
            FilterGraph*           graph,
            float                  min_range,
            float                  max_range,
            FilterEnv*             env,
            ResourcePackager*      packager,
            osgDB::Archive*        archive =NULL,
            osg::Referenced*       user_data =NULL );

        virtual void run();

        virtual void runSynchronousPostProcess( Report* report );

        const std::string& getCellId() const;

        const std::string& getLocation() const;

        OutputStatus getOutputStatus() const;

    private:
        std::string cell_id;
        std::string abs_output_uri;
        osg::ref_ptr<osgDB::Archive> archive;
        osg::ref_ptr<ResourcePackager> packager;
        bool need_to_compile;
        //bool has_drawables;
        float min_range, max_range;
        OutputStatus output_status;
    };}

#endif // _OSGGISPROJECTS_CELL_COMPILER_H_

